#include<iostream>
#include "Stock.h"


Stock::Stock()
{
	company = "no name";
	shares = 0;
	share_val = 0.0;
	total_val = 0.0;
}

Stock::~Stock()
{
}

Stock::Stock(const std::string& co, long n, double pr)
{
	company = co;
	if (n < 0) {
		std::cout << "Number of shares can't be nagative;"
			<< company << "shares set to 0. \n";
		shares = 0;
	}
	else shares = n;
	share_val = pr;
	Set_Tot();

}

const Stock& Stock::TopVal(const Stock& s) const
{
	if (s.total_val > total_val)
		return s;
	else
		return *this;
}

void Stock::Buy(long num, double price)
{
}

void Stock::Sell(long num, double price)
{
}

void Stock::Update(double price)
{
}

void Stock::Show() const
{
	using std::cout;
	using std::ios_base;

	// set format to #.###
	ios_base::fmtflags orig = cout.setf(ios_base::fixed, ios_base::floatfield);
	std::streamsize prec = cout.precision(3);

	cout << "Company: " << company
		<< "  Shares: " << shares << "\n";

	cout << "Share Price: $" << share_val;

	// set format to  #.##
	cout.precision(2);
	cout << " Total Worth: $" << total_val << "\n";

	// restore original format
	cout.setf(orig, ios_base::floatfield);
	cout.precision(prec);


}

